// pages/logDetail/logDetail.js
const app = getApp();
const util = require("../../utils/util.js");
const api = require("../../utils/api.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        order_sn:'',
        address: "",
        time: "2017-11-06 13:03",
        logs:'',
        address:'',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            order_sn: options.ordersn
        })
    },
    onReady: function () {
        util.setNavigationBarTitle("物流详情");
        this.ajax();
        this.address();
    },
    ajax:function(){
        var that =this;
        let url = api.express();
        util.http(true, "GET", url, { order_sn: that.data.order_sn},res=>{
            that.setData({
                logs: res.express
            })
        })
    },
    address:function(){
        var that = this;
        let url = api.orderDetail();
        util.http(true, "GET", url, { order_sn: that.data.order_sn }, res => {
            that.setData({
                address: res.address.address,
                time: util.formatAllTime(new Date(res.created_at * 1000))
            })
            
        })
    }
})